import React, { Component } from 'react';
import router from 'umi/router';
import { connect } from 'dva';
import PageHeaderWrapper from '@/components/PageHeaderWrapper';

@connect()
class PlatformSet extends Component {
  handleTabChange = key => {
    const { match } = this.props;
    switch (key) {
      case 'AdvertisingWheel':
        router.push(`${match.url}/AdvertisingWheel`);
        break;
      case 'Transaction':
        router.push(`${match.url}/Transaction`);
        break;
      case 'Contact':
        router.push(`${match.url}/Contact`);
        break;
      default:
        break;
    }
  };

  render() {
    const { children } = this.props;
    const tabList = [
      {
        key: 'AdvertisingWheel',
        tab: '广告轮播',
      },
      {
        key: 'Transaction',
        tab: '交易设置',
      },
      {
        key: 'Contact',
        tab: '联系方式',
      },
    ];
    return (
      <PageHeaderWrapper title="平台设置" onTabChange={this.handleTabChange} tabList={tabList}>
        {children}
      </PageHeaderWrapper>
    );
  }
}

export default PlatformSet;
